﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BadHabit.Factory.Reports {

    public class TailReport : Report {

        

        /// <summary>
        /// Implements a Report class to generate a backlog report.
        /// </summary>
        /// <param name="factory"></param>
        public TailReport(Factory factory) : base(factory) {}


        /// <summary>
        /// The template type name.
        /// </summary>
        public override string TemplateTypeName {
            get {
                return "TailReport";
            }
        }

      

        /// <summary>
        /// Adjusts the dataset for XPS render.
        /// </summary>
        /// <param name="projectUId">The projectUId</param>
        /// <returns>The adjusted dataset</returns>
        public override System.Data.DataSet CreateDataSet() {
            Data.ProjectDataSet ds = factory.RetriveProject(ProjectUId);
            if(ds.Project.Count>0) {
                //ProjectUId = ds.Project[0].ProjectUId;
                ProjectCategory = ds.Project[0].Category;
            }
            return ds;
        }

        public override System.Data.DataSet AdjustDataSet(System.Data.DataSet report) {
            report = base.AdjustDataSet(report);
            

            Data.TaskDataSet dsTask = factory.RetriveTailsByProjectUId(ProjectUId, ProjectCategory);
            
            dsTask.Merge(factory.RetriveImpactedItemsByProjectUId(ProjectUId));

            

            report.Merge(dsTask);

            return report;
        }

        
        
        

     


    }
}
